#encoding: utf-8
=begin

Usage:      This ruby file use to fix data errors in totem database caused by bugs

=end

load 'rds_api.rb'
load 'tutem_utils.rb'

#TPA2303053 修正积分流水
def fixTPA2303053
    sql = "select * from tutem_mall.eb_user_bill where category = 'integral' and type = 'deduction' and title = '积分抵扣'"

    (queryRds(sql)).each do |q|

        id = q['id']
        number = q['number']
        balance = q['balance']
        fixed_balance = balance - number

        usql = "update tutem_mall.eb_user_bill set title = '积分抵扣fixTPA2303053', number = #{number.to_f.round(2)}, balance = #{fixed_balance.to_f.round(2)} where id = #{id}"
        queryRds usql

    end
end
#fixTPA2303053
